﻿using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using Kaskelot.SP.Model.Contracts;
using Kaskelot.SP.Services;
using Stockholm.SOA.Kaskelot.WCF.DataContracts;

namespace Kaskelot.SP.UI.CONTROLTEMPLATES.Kaskelot.SP.UI.Forms
{
	public partial class ForsamlingForm : BaseForm, IForm
	{
		public string Id { get; set; }
		public string ParentId { get; set; }
		public Forsamling Current { get; set; }
		public IList<Valkrets> Valkretsar { get; set; }

		protected void Page_Load(object sender, EventArgs e)
		{
			using (AdminService svc = new AdminService())
			{
				Valkretsar = svc.GetValkretsar();

				if (!String.IsNullOrEmpty(Id))
				{
					Current = svc.GetForsamling(new Guid(Id));
				}
				else
				{
					Current = new Forsamling();
				}
			}

			IList<ListItem> valkretsar = new List<ListItem>();
			foreach (Valkrets vk in Valkretsar)
			{
				valkretsar.Add(new ListItem() { Text = vk.Namn, Value = vk.Id.ToString() });
			}
			ValkretsRepeater.DataSource = valkretsar;
			ValkretsRepeater.DataBind();
		}
	}
}
